/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.phieuthuedv;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.phieuthuedv.PhieuThueDVBORemote;
import uit.ejb.bo.phieuthuedv.PhieuThueDVBORemoteHome;
import uit.ejb.dto.PhieuThueDVDTO;

/**
 *
 * @author Restart
 */
public class PhieuThueDVController {

    private static Context ctx;
    private static PhieuThueDVBORemoteHome phome;
    private static PhieuThueDVBORemote ptdv;
    public PhieuThueDVController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/PhieuThueDVBO");
            phome = (PhieuThueDVBORemoteHome) PortableRemoteObject.narrow(obj, PhieuThueDVBORemoteHome.class);
            ptdv=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean phieuThueDV_Insert(PhieuThueDVDTO phieuthuedv) {
        try{
            Register();
            return ptdv.phieuThueDV_Insert(phieuthuedv);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean phieuThueDV_Delete(String id) {
        try{
            Register();
            return ptdv.phieuThueDV_Delete(id);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet phieuThueDV_GetById(String id) {
        try{
            Register();
            return ptdv.phieuThueDV_GetById(id);
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet phieuThueDV_GetByTop(String top, String where, String order) {
        try{
            Register();
            return ptdv.phieuThueDV_GetByTop(top, where, order);
        }catch(Exception e){
            return null;
        }
    }
}
